<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt" %>

<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Listings</title>

        <style>
            a {color:#404042;text-decoration:none;}      /* unvisited link */
            a:visited {color:#404042;}  /* visited link */
            a:hover {color:#404042;}  /* mouse over link */
            a:active {color:#404042;}  /* selected link */
            @font-face
            {
            font-family: avant;
            src: url('${model.props.appPath}/fonts/avangmi-webfont.ttf');
            }
        </style>
        <script type="text/javascript" src="js/jquery/jquery-1.8.3.min.js"></script>
        <script type="text/javascript" src="js/token/jquery.tokeninput.js"></script>    
        <script type="text/javascript">            
            $(document).ready(function() {
                $("#listings-table tr:odd").css("background-color", "#ececec");
            });
        </script>      
    </head>


    <body style="text-align: center; background-color: #FAFAFA; color: #404042; font-family: avant, Century Gothic, Calibri, Verdana; padding: 0px; margin: 0px;">                

        <div style="margin-top: 0px; background-color: white;">

            <%@include file="header.jsp" %>

            <div style="width: 100%; text-align: left; font-family: avant, Century Gothic, Calibri, Verdana; color: #404042; background-color: white; background: url('${model.props.appPath}/img/content-bg-short.jpg'); background-repeat: repeat-x; display: block; position: relative; top: -2px;">

                <div style="width: 1220px; margin-top: 10px; margin: 0 auto;">

                    <br>
                    
                    <h1>Listings Management</h1>
                    
                    <br>
                    
                    <table id="listings-table" border="1" cellpadding="5" cellspacing="5" style="width: 100%; font-size: 12px; border-collapse: collapse;">
                        <tr>
                            <th></th>
                            <th style="height: 50px">ID</th>
                            <th>Verified</th>
                            <th>Edit Info</th>
                            <th>Edit Photos</th>
                            <th>Has Photos</th>
                            <th>Has Places</th>
                            <th>Status</th>
                            <th>Post Date</th>
                            <th>Expiry Date</th>
                            <th>Spawn Date</th>
                            <th>Creator</th>
                            <th>Posted as</th>
                            <th>Email A</th>
                            <th>Email R</th>
                            <th>Email F</th>
                            <th>Email B</th>
                            <th>Email E</th>
                            <th>Penalized</th>
                            <th>Impress</th>
                            <th>Views</th>
                        </tr>                        
                        <tr>
                            <td colspan="20"></td>
                        </tr>
                        <c:set var="i" value="0"/>
                        <c:forEach items="${model.listings}" var="listing">
                            <c:set var="i" value="${i+1}"/>
                            <tr>
                                <td>${i}</td>
                                <td style="height: 50px"><a href="listing.htm?a=9002&id=${listing.id}" style="color: #369;">${listing.id}</a>
                                </td>
                                <td>
                                    <c:if test="${listing.verified}">
                                        <span style="color: darkgreen; font-weight: bold;">YES</span>
                                    </c:if>
                                    <c:if test="${!listing.verified}">
                                        <span style="color: red; font-weight: bold;">NO</span>
                                    </c:if>
                                </td>
                                <td><a href="listing.htm?a=9004&id=${listing.id}" style="color: #369;">Edit Info</a></td>
                                <td><a href="listing.htm?a=91003&id=${listing.id}" style="color: #369;">Edit Photo</a></td>
                                <td>
                                    <c:if test="${fn:length(listing.photoIDs) > 0}">
                                        <span style="color: darkgreen; font-weight: bold;">YES</span>
                                    </c:if>                                 
                                    <c:if test="${fn:length(listing.photoIDs) <= 0}">
                                        <span style="color: red; font-weight: bold;">NO</span>
                                    </c:if>                                       
                                </td>
                                <td>
                                    <c:if test="${fn:length(listing.placeIDs) > 0}">
                                        <span style="color: darkgreen; font-weight: bold;">YES</span>
                                    </c:if>                                 
                                    <c:if test="${fn:length(listing.placeIDs) <= 0}">
                                        <span style="color: red; font-weight: bold;">NO</span>
                                    </c:if>                                                  
                                </td>
                                <td align="center">
                                    <c:if test="${listing.posted}">
                                        <span style="color: darkgreen; font-weight: bold; font-size:14px">Posted</span>
                                    </c:if>
                                    <c:if test="${!listing.posted}">
                                        <span style="color: red; font-weight: normal;">Not Posted</span>
                                    </c:if>
                                </td>
                                <td align="center">
                                    <c:if test="${listing.posted}">
                                        <fmt:formatDate value="${listing.postDate}" pattern="MMMM dd, yyyy" />
                                    </c:if>
                                    <c:if test="${!listing.posted}">
                                        N/A
                                    </c:if>
                                </td>
                                
                                <td align="center">
                                    <c:if test="${listing.posted}">
                                        <fmt:formatDate value="${listing.expiryDate}" pattern="MMMM dd, yyyy" />
                                    </c:if>
                                    <c:if test="${!listing.posted}">
                                        N/A
                                    </c:if>
                                </td>
                                
                                <td align="center">
                                    <c:if test="${listing.posted}">
                                        <fmt:formatDate value="${listing.spawnDate}" pattern="MMMM dd, yyyy" />
                                    </c:if>
                                    <c:if test="${!listing.posted}">
                                        N/A
                                    </c:if>
                                </td>
                                
                                <td><a href="user.htm?a=2&id=${listing.creatorID}" style="color: #369;">${listing.creator.firstName} ${listing.creator.lastName}</a></td>
                                <td>${listing.posterTypeID}</td>
                                <td>
                                    <a href="listing.htm?a=15001&id=${listing.id}" style="color: green">Approve</a>                                     
                                </td>
                                <td>
                                    <a href="listing.htm?a=15002&id=${listing.id}" style="color: orangered">Reject</a>                                     
                                </td>
                                <td>
                                    <a href="listing.htm?a=15003&id=${listing.id}" style="color: orangered">Featured</a>                                     
                                </td>
                                <td>
                                    <a href="listing.htm?a=15004&id=${listing.id}" style="color: mediumvioletred">Boost</a>                                     
                                </td>
                                <td>
                                    <a href="listing.htm?a=15005&id=${listing.id}" style="color: mediumvioletred">Ended</a>                                     
                                </td>
                                <td>
                                    <c:if test="${listing.penalized}">
                                        <span style="color: red;">penalized</span><br> 
                                        <a href="listing.htm?a=12000&id=${listing.id}&penalize=2" style="color: blue">un-Penalize/a>                                        
                                    </c:if>
                                    <c:if test="${!listing.penalized}">
                                        ${listing.penalized} <br>
                                        <a href="listing.htm?a=12000&id=${listing.id}&penalize=1" style="color: red">Penalize</a>                                      
                                    </c:if>                                    
                                </td>
                                <td>${listing.impressions}</td>
                                <td>${listing.views}</td>
                            </tr>
                            <tr>
                                <td colspan="20"></td>
                            </tr>
                        </c:forEach>
                    </table>

                </div>

                <br><br>                

            </div>

            <div>
                <img src="${model.props.appPath}/img/footer-foot.jpg" style="border: 0px solid black; display: block; width: 100%;" />
            </div>

        </div>

    </body>

</html>
